﻿using Smobiler.Core;
using Smobiler.Core.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL;
using FubiManger.UI;

namespace FubiManger.Controls
{
    ////ToolboxItem用于控制是否添加自定义控件到工具箱，true添加，false不添加
    //[System.ComponentModel.ToolboxItem(true)]
    partial class Addclassifycontrol : Smobiler.Core.Controls.MobileUserControl
    {
        public Addclassifycontrol() : base()
        {
            //This call is required by the SmobilerUserControl.
            InitializeComponent();
        }
        /// <summary>
        /// 商户ID
        /// </summary>
        public string merchantid { get; set; }
        /// <summary>
        /// 排序编号
        /// </summary>
        public int sort { get; set; }

        private void btnsave_Press(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtitle.Text))
            {
                if (classifyDal.Querybyname(txtitle.Text, merchantid) > 0)
                {
                    MessageBox.Show("该分类名称已存在");
                }
                else
                {
                    if (classifyDal.Addclassify(merchantid, txtitle.Text, sort) > 0)
                    {
                        MessageBox.Show("添加分类成功", (obj, args) =>
                        {
                            ((MainForm)this.Form).Resfhclassify();//刷新分类
                        this.Close();
                        });
                    }
                }
            }
            else
            {
                MessageBox.Show("请填写分类名称");
            }
        }

        private void btnclose_Press(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}